Skip to content

Add prettier and eslint for consistent code#14

Closed
pakeku wants to merge 8 commits intomasterfrom
erick/profile
Closed

Add prettier and eslint for consistent code#14
pakeku wants to merge 8 commits intomasterfrom
erick/profile

Conversation

@pakeku
Copy link
Copy Markdown
Owner

@pakeku pakeku commented May 17, 2025

No description provided.

@pakeku pakeku requested a review from Copilot May 17, 2025 05:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates Prettier and ESLint for consistent code formatting and linting across the project.

  • Adds Prettier and ESLint configs, updates package.json scripts accordingly
  • Reformats imports and code ordering in middleware, tests, and database modules
  • Introduces graceful shutdown logic, refines type annotations, and uses nullish coalescing

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/midleware/morgan.ts Simplified import by removing unused StreamOptions
src/midleware/json.ts Reordered JSON middleware options and tightened reviver types
src/midleware/helmet.ts Reordered helmet options and moved referrerPolicy
src/midleware/errorHandler.ts Marked unused params, disabled lint warning, added stack fallback
src/midleware/cors.ts Switched env defaults to nullish coalescing and trimmed arrays
src/index.ts Added dotenv import, graceful shutdown, updated startServer()
src/http_tests/stores.test.ts Added type casts, extracted body, conditional ID checks
src/http_tests/authentication.test.ts Defined response interface, typed responses, added profile test
src/http_tests/app.test.ts Added response interface, unified status assertions
src/database/stores.ts Refactored CRUD returns, moved getStores(), type-safe mapping
src/database/mongo-common.ts Reordered imports, env var fallback, unified getDatabase()
src/app.ts Reordered middleware imports
package.json Added private flag, import maps, lint/format scripts, deps
eslint.config.js New ESLint configuration
README.md Updated environment docs and scripts examples
.prettierrc New Prettier configuration
.prettierignore Added ignore patterns
.env.sample Added JWT_SECRET to sample variables
Comments suppressed due to low confidence (2)

src/http_tests/stores.test.ts:55

  • The test silently skips assertions when storeId is undefined, potentially hiding failures. Add an explicit expect(storeId).toBeDefined() before the conditional to ensure the setup succeeded.
if (storeId) {

README.md:17

  • The environment variable name is mistyped as NODE\*ENV. It should read NODE_ENV=test and the markdown escaping can be simplified for clarity.
6. NODE\*ENV=test --- When set to \*\*\*"test"\_\*\*...

Comment thread src/http_tests/authentication.test.ts Outdated
.expect(200);

expect(res.statusCode).toEqual(200);
expect(body).toHaveProperty('email', testUser.email);
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion uses body from the login response instead of the profile response. You should extract and assert against the res.body of the GET /auth/me request.

Suggested change
expect(body).toHaveProperty('email', testUser.email);
const profileBody = res.body;
expect(profileBody).toHaveProperty('email', testUser.email);

Copilot uses AI. Check for mistakes.
Comment thread src/database/stores.ts Outdated
const database = await getDatabase();
const stores = await database.collection<Store>(collectionName).find({}).toArray();
return stores.map(store => ({
_id: new ObjectId(store._id),
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-wrapping an existing ObjectId is unnecessary and could lead to confusion; you can return store._id directly since it’s already the correct type.

Suggested change
_id: new ObjectId(store._id),
_id: store._id,

Copilot uses AI. Check for mistakes.
Comment thread src/index.ts Outdated
});

startServer(); No newline at end of file
void startServer() No newline at end of file
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add a semicolon after void startServer() to comply with the project's Prettier semi: true rule and maintain consistency.

Suggested change
void startServer()
void startServer();

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@pakeku pakeku closed this May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants